package com.ssy.lingxi.system.controller;

import com.ssy.lingxi.common.response.PageData;
import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.system.dto.request.LanguageDeleteRequest;
import com.ssy.lingxi.system.dto.request.LanguageListRequest;
import com.ssy.lingxi.system.dto.request.LanguageRequest;
import com.ssy.lingxi.system.dto.response.LanguageListResponse;
import com.ssy.lingxi.system.entity.Language;
import com.ssy.lingxi.system.service.LanguageService;
import com.ssy.lingxi.system.utils.UserDetailsUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
 * @menu 基础设置-语言设置管理
 * @author wrc
 * @date 2020/7/20
 */
@Api(tags = "基础设置语言设置管理")
@RestController
public class LanguageController {
    @Resource
    LanguageService languageService;
    @Autowired
    UserDetailsUtil userDetailsUtil;

    @ApiOperation(value = " 查询语言设置列表")
    @GetMapping("/language/list")
    public Wrapper<PageData<LanguageListResponse>> languageList(LanguageListRequest request) {
        return languageService.languageList(request);
    }

    @ApiOperation(value = " 添加语言设置")
    @PostMapping("/language/add")
    public Wrapper<Void> languageAdd(@RequestBody Language request, HttpServletRequest httpServletRequest) {
        return languageService.languageAdd(httpServletRequest,request);
    }

    @ApiOperation(value = "修改语言设置")
    @PostMapping("/language/update")
    public Wrapper<Void> languageUpdate(@RequestBody Language request,HttpServletRequest httpServletRequest) {
        return languageService.languageUpdate(httpServletRequest,request);
    }


    @ApiOperation(value = "删除语言设置")
    @PostMapping("/language/delete")
    public Wrapper<Void> languageDelete(@RequestBody LanguageDeleteRequest request,HttpServletRequest httpServletRequest) {
        return languageService.languageDelete(httpServletRequest,request);
    }


    @ApiOperation(value = "查询语言设置详情")
    @GetMapping("/language/details")
    public Wrapper<LanguageListResponse> languageDetails(LanguageRequest request) {
        return languageService.languageDetails(request);
    }


    @ApiOperation(value = "查询语言设置全部")
    @GetMapping("/language/all")
    public Wrapper<List<Language>> languageAll() {
        return languageService.languageAll();
    }


    @ApiOperation(value = "停用&启用语言设置全部")
    @PostMapping("/language/update/state")
    public Wrapper<Void> languageStop(@RequestBody LanguageDeleteRequest request) {
        return languageService.languageStop(request);
    }




}
